<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\signup\model;

use app\activity\model\activity;
use plugin\saiadmin\basic\BaseModel;

/**
 * 报名列表模型
 */
class signup extends BaseModel
{

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'signup_id';

    /**
     * 数据库表名称
     * @var string
     */
    protected $table = 'eb_signup';
    public $append = ['activity_id_text'];
    
    /**
     * 会员姓名 搜索
     */
    public function searchMemberNameAttr($query, $value)
    {
        $query->where('member_name', 'like', '%'.$value.'%');
    }
    
    /**
     * 手机号码 搜索
     */
    public function searchPhoneNumberAttr($query, $value)
    {
        $query->where('phone_number', 'like', '%'.$value.'%');
    }
    
    /**
     * 公司名称 搜索
     */
    public function searchCompanyNameAttr($query, $value)
    {
        $query->where('company_name', 'like', '%'.$value.'%');
    }
    
    /**
     * 公司职务 搜索
     */
    public function searchCompanyPositionAttr($query, $value)
    {
        $query->where('company_position', 'like', '%'.$value.'%');
    }

    public function getActivityIdTextAttr($value,$data)
    {
        if(isset($data['activity_id'])){
          return    activity::where('activity_id', $data['activity_id'])->value('activity_title');
        }
        return '';
    }


}
